﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;

namespace exercice2
	{
	class Program
		{
		/*---------------------------------------------*\
		|*               Methodes public               *|
		\*---------------------------------------------*/
		static void Main(string[] args)
			{
			main();
			}

		public static void main()
			{
			partA();
			System.Console.ReadKey();
			}

		/*---------------------------------------------*\
		|*              Methodes private               *|
		\*---------------------------------------------*/
		private static void partA()
			{
			List<Object> listObjects = new List<Object>();
			enterData(listObjects);
			displayList(listObjects);
			}

		private static void displayList(List<Object> list)
			{
			foreach(var item in list)
				{
				System.Console.WriteLine(item.ToString() + " : " + item.GetType());
				}
			}

		private static void enterData(List<Object> list)
			{
			bool isFinished = false;
			do
				{
				System.Console.WriteLine("Enter anything : ");
				String line = System.Console.ReadLine();

				//Si l'entrée n'est pas vide
				if(line.Length != 0)
					{
					//Test si c'est un nombre entier
					try
						{
						var value = Convert.ToInt32(line);
						list.Add(value);
						}
					catch(Exception)
						{
						//Test si c'est un nombre flottant
						try
							{
							var value = Convert.ToDouble(line, CultureInfo.InvariantCulture.NumberFormat);
							list.Add(value);
							}
						catch(Exception)
							{
							//Test si c'est un seul caractère sinon c'est une chaine de caractère
							if(line.Length == 1)
								{
								list.Add(line.ToCharArray()[0]);
								}
							else
								{
								list.Add(line);
								}
							}
						}
					}
				else
					{
					isFinished = true;
					}

				} while(!isFinished);
			}
		}
	}
